<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:29:"../template/admin\artice.html";i:1534513971;s:27:"../template/admin/head.html";i:1534246619;}*/ ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>
文章管理_后台管理
</title>
  <link rel="stylesheet" href="/blog/public/static/admin/layui/css/index.css">
  <link rel="stylesheet" href="/blog/public/static/admin/layui/css/layui.css">
  
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo"><i class="layui-icon layui-icon-set-fill"></i>网站后台管理</div>
    <!-- 头部区域（可配合layui已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <li class="layui-nav-item"><a href="<?php echo URL('user/index'); ?>">控制台首页</a></li>
      <li class="layui-nav-item"><a href="<?php echo URL('index'); ?>">网站首页</a></li>
      </li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item">
        <a href="javascript:;">
          <img src="/blog/public/static/index/images/face.png" class="layui-nav-img">
          <?php echo $nickname; ?>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="<?php echo URL('User/userset'); ?>">个人设置</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item"><a href="<?php echo URL('User/userexit'); ?>">注销</a></li>
    </ul>
  </div>
  
  <div class="layui-side layui-bg-black qqadmin">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree"  lay-filter="test">
        <li class="layui-nav-item">
          <a href="javascript:;">网站管理</a>
          <dl class="layui-nav-child">
            <dd><a href="<?php echo URL('Systemset/index'); ?>">网站设置</a></dd>
            <dd><a href="<?php echo URL('Systemset/nav'); ?>">导航设置</a></dd>
            <dd><a href="<?php echo URL('Link/index'); ?>">友情链接</a></dd>
          </dl>
        </li>
          <li class="layui-nav-item">
          <a href="javascript:;">文章管理</a>
          <dl class="layui-nav-child">
            <dd><a href="<?php echo URL('Artice/articeadd'); ?>">添加文章</a></dd>
            <dd><a href="<?php echo URL('Artice/index'); ?>">文章管理</a></dd>
            <dd><a href="<?php echo URL('Comments/index'); ?>">评论管理</a></dd>
            <dd><a href="<?php echo URL('Artice/articeclass'); ?>">分类管理</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="<?php echo URL('Twitters/index'); ?>">微语管理</a></li>
        <li class="layui-nav-item"><a href="<?php echo URL('User/userset'); ?>">个人设置</a></li>
        <li class="layui-nav-item"><a href="<?php echo URL('Page/index'); ?>">独立页面</a></li>
      </ul>
    </div>
  </div>
  <div class="layui-body">
    <!-- 内容主体区域 -->
    
<blockquote class="layui-elem-quote news_search">
    <div class="layui-inline">
      <a class="layui-btn layui-btn-normal newsAdd_btn" href="<?php echo URL('Artice/articeadd'); ?>">添加文章</a>
    </div>
    <div class="layui-inline">
      <div class="layui-form-mid layui-word-aux"> 说明：文章的修改与删除。</div>
    </div>
  </blockquote>
  <div class="layui-form news_list">
      <table class="layui-table">
        <colgroup>
        <col width="50">
        <col width="150">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="9%">
        <col width="15%">
        </colgroup>
        <thead>
        <tr>
         <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"> 全选</th>
          <th style="text-align:left;">文章标题</th>
          <th>发布人</th>
          <th>推荐</th>
          <th>分类</th>
          <th>是否展示</th>
          <th>发布时间</th>
          <th>操作</th>
        </tr> 
        </thead>
        <tbody class="news_content">
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <tbody>
<?php if(is_array($artice) || $artice instanceof \think\Collection || $artice instanceof \think\Paginator): $i = 0; $__LIST__ = $artice;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$artice): $mod = ($i % 2 );++$i;?>
    <tr id="data<?php echo $artice['id']; ?>">
      <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"></th>
      <td><?php echo $artice['title']; ?></td>
      <td><?php echo $artice['author']; ?></td>
      <td>
      <button class="layui-btn <?php if(($artice['top'] == 0)): else: ?>layui-btn-danger<?php endif; ?>" title="点击修改状态" onclick="topstatus(<?php echo $artice['id']; ?>)"><?php if(($artice['top'] == 1)): ?>Y<?php else: ?>N<?php endif; ?></button>
      </td>
      <td><?php echo $artice['name']; ?></td>
      <td>
      <button class="layui-btn <?php if(($artice['show'] == 1)): else: ?>layui-btn-danger<?php endif; ?>" title="点击修改状态" onclick="showstatus(<?php echo $artice['id']; ?>)"><?php if(($artice['show'] == 0)): ?>N<?php else: ?>Y<?php endif; ?></button>
      </td>
      <td>2016-11-29</td>
      <td><div class="layui-btn-group">
  <a href="<?php echo URL('Artice/articeedit'); ?>?id=<?php echo $artice['id']; ?>" class="layui-btn">编辑</a>
  <button class="layui-btn" onclick="delac(<?php echo $artice['id']; ?>)">删除</button>
</div></td>
    </tr>
<?php endforeach; endif; else: echo "" ;endif; ?>
  </tbody>
</div>

  </div>
  
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    © Xiele 2018
  </div>
</div>
<script src="/blog/public/static/admin/layui/js/jquery.min.js"></script>
<script src="/blog/public/static/admin/layui/layui.js"></script>

<script type="text/javascript">
  layui.use(['form', 'layedit', 'laydate'], function() {
    var form = layui.form,
    layer = layui.layer,
    layedit = layui.layedit,
    laydate = layui.laydate;

  });
  //删除文章数据
function delac(id){
layer.confirm('确认删除此文章？', {
  btn: ['确认','取消'] //按钮
}, function(){
  if (id != "") {
        $.ajax({
          type:"POST",
          url:"<?php echo URL('Artice/acdel'); ?>",
          dataType:"json",
          data:{id:id},
          beforeSend: function () {
            // 动画显示
            layer.load(1);
            },
           error: function (XmlHttpRequest, textStatus, errorThrown) {
              if (XmlHttpRequest.responseText != "") {
                  layer.closeAll('loading');
                  layer.msg('提交失败，请稍后尝试！');
              }
          },
          success:function(data){
            //1为删除成功
            //2为删除失败
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              $('#data'+id).remove();
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
            }
          }
        });
        return false;
    }else{
      layer.msg('ID值为空!');
      return false;
    }
});
}
//修改显示状态
function showstatus(id){
        $.ajax({
          type:"POST",
          url:"<?php echo URL('Artice/showstatus'); ?>",
          dataType:"json",
          data:{id:id},
          beforeSend: function () {
            // 加载动画
            layer.load(1);
            },
           error: function (XmlHttpRequest, textStatus, errorThrown) {
              if (XmlHttpRequest.responseText != "") {
                  layer.closeAll('loading');
                  layer.msg('提交失败，请稍后尝试！');
              }
          },
          success:function(data){
            //1为添加成功
            //2为添加失败
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              setTimeout(function(){
                location.reload();
              },1000);
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
            }
          }
        });
}
//修改置顶状态
function topstatus(id){
        $.ajax({
          type:"POST",
          url:"<?php echo URL('Artice/topstatus'); ?>",
          dataType:"json",
          data:{id:id},
          beforeSend: function () {
            // 加载动画
            layer.load(1);
            },
           error: function (XmlHttpRequest, textStatus, errorThrown) {
              if (XmlHttpRequest.responseText != "") {
                  layer.closeAll('loading');
                  layer.msg('提交失败，请稍后尝试！');
              }
          },
          success:function(data){
            //1为添加成功
            //2为添加失败
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              setTimeout(function(){
                location.reload();
              },1000);
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
            }
          }
        });
}
</script>

<script>
//JavaScript代码区域
layui.use('element', function(){
  var element = layui.element;
  
});
</script>
</body>
</html>